Apple APIs topic
Generating bindings for Apple APIs
It can be tricky to locate header files containing Apple's Objective-C frameworks, and
the paths can vary between computers depending on which version of Xcode you are
using and where it is installed. FFIgen provides helper getters that can be used
when configuring Input.entryPoints:
xcodeUri/xcodePath: The directory where Xcode's APIs are installed (resolved viaxcode-select -p).iosSdkUri/iosSdkPath: The directory within Xcode where the iOS SDK is installed (resolved viaxcrun --show-sdk-path --sdk iphoneos).macSdkUri/macSdkPath: The directory within Xcode where the macOS SDK is installed (resolved viaxcrun --show-sdk-path --sdk macosx).
For example:
final generator = FfiGenerator(
input: Input(
entryPoints: [
// Use macSdkUri to resolve headers within the macOS SDK.
macSdkUri.resolve(
'System/Library/Frameworks/Foundation.framework/Headers/NSDate.h',
),
],
),
output: Output(dart: DartOutput(path: Uri.file('nsdate.dart'))),
);
Classes
- FfiGenerator Apple APIs Objective-C Memory Management Objective-C Method Filtering Dealing with OS Differences Objective-C Runtime Types Objective-C Threading Errors FAQ
-
The generator that generates bindings for
dart:ffifrom C and Objective-C headers.